/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "节点/节点.h"




union U_通用数据联合 {
	std::vector<S_Rect2Df> Rect2Df;

	U_通用数据联合(){
		Rect2Df = {};
	};

	~U_通用数据联合(){}
};



class C_引用数据插座 : public C_插座基类 {
	
public:
	C_引用数据插座(std::wstring name);
	~C_引用数据插座();
	
	S_引用插座数据映射		m_引用数据;
	
	void*					f_getData(uint8 线程ID);
	//vec3					f_getVec3(uint8 线程ID);
	//std::vector<int8>*		f_getI8_1D(const int64& ID = -1);
	//std::vector<float32>*	f_getF32_1D(const int64& ID = -1);
	//std::vector<vec3>*		f_getVec3_1D(const int64& ID = -1);
	//std::vector<S_Rect2Df>*	f_getRect2Df_1D(const int64& ID = -1);
	void					f_setData(void* data, uint8 线程ID);
	void					f_setData(S_引用插座数据映射* data, uint8 线程ID = 0);
	std::wstring		f_getTypeName() { return L"引用"; }
	//PyObject* f_输出_bl数据(PyObject* bl_data = 0);
	
};
#define DEF_转换为引用插座(socket) dynamic_cast<C_引用数据插座*>( (socket) )
#define DEF_引用插座数据(socket, loc) ((S_引用插座数据映射*)((socket)->f_getData(loc)))

#define DEF_创建引用插座_I(name)  socket = new C_引用数据插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建引用插座_O(name)  socket = new C_引用数据插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);


#define DEF_引用转F32(data) ((float32*)data.m_Data)
#define DEF_引用转I32(data) ((int32*)data.m_Data)
#define DEF_引用转UI32(data) ((uint32*)data.m_Data)
#define DEF_引用转UI32S(data) ((std::vector<uint32>*)data.m_Data)
#define DEF_引用转Vec3(data) ((vec3*)((data).m_Data))
#define DEF_引用转mat3X3(data) ((mat3X3*)((data).m_Data))
#define DEF_引用转Vec2_1D(data) ((std::vector<vec2>*)((data).m_Data))
#define DEF_引用转Vec3_1D(data) ((std::vector<vec3>*)((data).m_Data))
#define DEF_引用转Cude_1D(data) ((std::vector<S_Cube>*)((data).m_Data))
//#define DEF_引用转VEC3(data) ((vec3*)((data).m_Data))
#define DEF_引用转Vec4_1D(data) ((std::vector<vec4>*)((data).m_Data))
#define DEF_引用转VN(data) ((S_VN*)((data).m_Data))
#define DEF_引用转VN_1D(data) ((std::vector<S_VN>*)((data).m_Data))
#define DEF_引用转VecSphere_1D(data) ((std::vector<S_VecSphere>*)((data).m_Data))
#define DEF_引用转线段(data) ((S_线段*)data.m_Data)
#define DEF_引用转线段_1D(data) ((std::vector<S_线段>*)data.m_Data)
#define DEF_引用转八叉树(data) ((S_点距八叉树*)data.m_Data)
#define DEF_引用转路径树(data) ((std::vector<S_八叉树子空间*>*)data.m_Data)
#define DEF_引用转MESH(data) ((S_Mesh*)((data).m_Data))
#define DEF_引用转MESH_1D(data) ((std::vector<S_Mesh*>*)((data).m_Data))
#define DEF_引用转物体(data) ((S_物体*)data.m_Data)
#define DEF_引用转骨架(data) ((S_骨架*)data.m_Data)
#define DEF_引用转骨骼(data) ((S_物体*)data.m_Data)
#define DEF_引用转物体_1D(data) ((std::vector<S_物体*>*)data.m_Data)
#define DEF_引用转体素(data) ((S_体素*)((data).m_Data))
#define DEF_引用转四元数(data) ((Quat*)((data).m_Data))
#define DEF_引用转物理体(data) ((S_物理体*)((data).m_Data))
#define DEF_引用转物理体_1D(data) ((std::vector<S_物理体*>*)((data).m_Data))
#define DEF_引用转粒子系统(data) ((S_粒子插座数据*)((data).m_Data))
#define DEF_引用转矩阵_1D(data) ((std::vector<C_Mat44>*)((data).m_Data))
#define DEF_引用转矩阵(data) ((C_Mat44*)((data).m_Data))
#define DEF_引用转IK(data) ((S_骨骼IK*)((data).m_Data))




class C_通用数据插座 : public C_插座基类 {
	

public:
	C_通用数据插座(std::wstring name);
	~C_通用数据插座();

	
	E_值类型	m_插座数据类型;
	void*		m_Data;

	void* f_getData(uint8 线程ID);
	//vec3					f_getVec3(uint8 线程ID);
	//std::vector<int8>*		f_getI8_1D(const int64& ID = -1, uint8 线程ID = 0);
	//std::vector<float32>*	f_getF32_1D(const int64& ID = -1, uint8 线程ID = 0);
	//std::vector<vec3>*		f_getVec3_1D(const int64& ID = -1, uint8 线程ID = 0);
	std::vector<S_Rect2Df>* f_getRect2Df_1D(uint8 线程ID = 0);

	void					f_setData(void* data, uint8 线程ID = 0);

	//PyObject* f_输出_bl数据(PyObject* bl_data = 0);

};
#define DEF_通用数据插座(socket) dynamic_cast<C_通用数据插座*>( (socket) )
#define DEF_通用数据插座数据(socket) ((S_引用插座数据映射*)((socket)->f_getData(0)))

#define DEF_通用数据插座创建_I(name)  socket = new C_通用数据插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_通用数据插座创建_O(name)  socket = new C_通用数据插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);









class C_板载缓存插座 : public C_插座基类 {

public:
	C_板载缓存插座(std::wstring name);
	~C_板载缓存插座();

	std::vector<S_板载缓存*> m_Value;

	virtual void*	f_getData(uint8 线程ID);
	void			f_setData(void* data, uint8 线程ID = 0);

	void	f_读取(FILE* f);
	void	f_写入(FILE* f);

	std::wstring		f_getTypeName() { return L"[mem]"; }
};

#define DEF_板载缓存_1D插座(socket)		dynamic_cast<C_纹理1D插座*>( (socket) )
#define DEF_板载缓存插座_1D数据(socket, tid)	( (std::vector<S_板载缓存*>*)((socket)->f_getData(tid)) )

#define DEF_创建板载缓存_1D插座_I(name)  socket = new C_纹理1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输入);
#define DEF_创建板载缓存_1D插座_O(name)  socket = new C_纹理1D插座( (name) ); f_add插座(socket, E_插座方向::e_插座Type_输出);






